import subprocess

from django.core.management.base import BaseCommand
from ability.models import VncServer
from study.utils import kill_process_by_port

class Command(BaseCommand):
    help = 'recoveryvncport'

    def handle(self, *args, **options):
        vncServers = VncServer.objects.values('host', 'port')
        for item in vncServers:
            kill_process_by_port(item['port'])
        VncServer.objects.filter(id__gt=0).delete()



